package com.wing.cabinet.model.entity;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 暂存柜存刀/取刀;存/取维修/回收刀
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_storage_inventory_inout")
public class StorageInventoryInout extends BaseEntity<StorageInventoryInout> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum OperationType implements IEnum<Integer> {

        /**
        * 存刀
        */
        in(1,"存刀"),
        /**
        * 取刀
        */
        out(2,"取刀");

        private int code;
        private String desc;

        OperationType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum BusinessType implements IEnum<Integer> {
        losed(0,"缺失"),
        /**
        * 暂存
        */
        temp(1,"暂存"),
        /**
        * 维修
        */
        repair(2,"维修"),
        /**
        * 回收
        */
        recycle(3,"报废"),

        outByReturned(5,"归还仓库管理员"),

        /**
         * 格子柜上货
         */
        exhibit(4,"格子柜上货"),

        loss(7,"报失"),

        unload(8,"格子柜下货");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum BusinessTypeChecked implements IEnum<Integer> {
        losed(0,"缺失"),
        /**
         * 暂存
         */
        temp(1,"暂存"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 回收
         */
        recycle(3,"报废");

        private int code;
        private String desc;

        BusinessTypeChecked(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessTypeChecked jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessTypeChecked item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    public enum Status implements IEnum<Integer> {

        /**
        * 已创建/待盘验
        */
        created(0,"待盘验"),
        /**
        * 已盘验
        */
        checked(1,"已盘验"),
        /**
        * 已通知/回收中
        */
        notified(2,"已通知/回收中"),
        /**
        * 平台已取货/已回收
        */
        taked(3,"平台已取货/已回收"),
        /**
        * 已签收/已完成
        */
        signed(4,"已签收/已完成");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static Status jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (Status item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 存刀任务编号
     */
    private String code;

    /**
     * no
     */
    private Integer no;

    /**
     * day
     */
    private Integer day;

    /**
     * 操作类型
     */
    private OperationType operationType;

    /**
    * 操作类型描述
    */
    @TableField(exist = false)
    private String operationTypeDesc;

    public String getOperationTypeDesc() {
        return operationType == null ? null : operationType.getDesc();
    }

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
     * 业务类型
     */
    private BusinessTypeChecked businessTypeChecked;

    /**
    * 业务类型描述
    */
    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
    * 盘验时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime checkTime;

    /**
     * 盘验人id
     */
    private Long checkUserId;

    /**
     * 盘验人
     */
    private String checkUserName;

    /**
    * 通知时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime notifyTime;

    /**
     * 通知人
     */
    private Long notifyUserId;

    /**
     * 通知人
     */
    private String notifyUserName;

    /**
     * 回收人id
     */
    private Long takeUserId;

    /**
     * 回收人
     */
    private String takeUserName;

    /**
    * 回收时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime takeTime;

    /**
     * 签收人id
     */
    private Long signUserId;

    /**
     * 签收人
     */
    private String signUserName;

    /**
     * 签收时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime signTime;

    private Long checkedResultId;

    /**
     * 供应商id
     */
    private Long supplierId;

    /**
     * 供应商名称
     */
    private String supplierName;

    public enum IsSyns implements IEnum<Integer> {

        /**
         * 未同步
         */
        no(0,"未同步"),
        /**
         * 已同步
         */
        yes(1,"已同步");

        private int code;
        private String desc;

        IsSyns(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }
    private StorageInventoryInout.IsSyns isSyns;

    /**
     * 设备编号
     */
    private String deviceCode;


    private Boolean isCheck;

    private Long supplierCompanyId;

    private Long companyId;

    private String creatorNickname;


    public enum BusinessDetailType implements IEnum<Integer> {

        /**
         * 业务类型:cellCabReceive(1,售刀柜领取);repairOrderSign(2,维修订单签收)
         */
        cellCabOut(1,"售刀柜领新"),

        tempIn(2,"存入暂存柜"),
        /**
         * 领取
         */
        repairOrderSign(3,"维修订单签收"),

        tempOut(4,"暂存柜取出"),

        outByReturned(5,"归还仓库管理员"),

        cellCabOutByOldNew(6,"售刀柜领新(以旧换新)"),

        /**
         * 维修
         */
        repairIn(7,"维修存入"),
        /**
         * 回收
         */
        recycleIn(8,"报废存入"),


        repairOutByCheck(9,"盘验维修取出"),

        recycleOutByCheck(10,"盘验报废取出"),

        recycleInByOldNew(11,"以旧换新存入报废"),

        tempInByCheck(12,"盘验暂存存入"),

        tempOutByCheck(13,"盘验暂存取出"),

        tempOutByCheckLose(14,"盘验暂存缺失"),

        repairOutByCheckLose(15,"盘验维修缺失"),

        recycleOutByCheckLose(16,"盘验报废缺失"),

        tempInByOldNew(17,"以旧换新存入暂存"),

        repairInByOldNew(18,"以旧换新存入维修"),

        tempOutByCheckSpec(19,"盘验暂存产品规格不相符"),

        repairOutByCheckSpec(20,"盘验维修产品规格不相符"),

        recycleOutByCheckSpec(21,"盘验报废产品规格不相符"),

        importUseByExcel(22,"导入在用刀具"),

        virtualOutByCheck(23,"维修报废盘验为暂存取出"),

        newOut(24,"存刀柜新刀取出"),

        loss(31,"报失"),

        exhibit(32,"格子柜上货"),

        unload(33,"格子柜下货");


        private int code;
        private String desc;

        BusinessDetailType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessDetailType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessDetailType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    private BusinessDetailType businessDetailType;

    public enum BusinessTypePre implements IEnum<Integer> {
        losed(0,"缺失"),
        /**
         * 暂存
         */
        temp(1,"暂存"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 回收
         */
        recycle(3,"报废");

        private int code;
        private String desc;

        BusinessTypePre(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessTypePre jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessTypePre item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    private BusinessTypePre businessTypePre;


    private Long useInventoryInoutId;

    private Long checkInventoryInoutId;

    private Long storageInventoryOutId;

    @TableField(exist = false)
    private Long storageInventoryCheckId;

    private Long workOrderId;


    private Long departmentId;

    private String departmentName;

    /**
     * 企业编码
     */
    private String enterpriseCode;


    /**
     * 同步时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime synsTime;

    private BigDecimal total;

    private Long processId;

    @TableField(exist = false)
    private List<String> LabelCodeList;
    /**
     * 渠道编号
     */
    private String channelCode;
    private String roleName;

    private Long roleId;

    private String remark;
    private String costCenter;

    /**
     * 主柜编号
     */
    private String mainCabCode;
}
